#include "Camera.h"

namespace poly
{

	Camera::Camera()
	{

	}

	float44 Camera::view()
	{
		if( hand == RIGHTHANDED )
		{
			return lookAtRH( eye, at, up );
		}
		else if( hand == LEFTHANDED )
		{
			return lookAtLH( eye, at, up );
		}
	}

	float44 Camera::projection()
	{
		switch( hand )
		{
		case RIGHTHANDED:
			{
				switch( projectionType )
				{
				case ORTHO:
					return orthoRH( ortho.w, ortho.h, zn, zf );
					break;
				case ORTHO_OFFCENTER:
					return orthoOffCenterRH( orthoOffCenter.l, orthoOffCenter.r,
						orthoOffCenter.b, orthoOffCenter.t, zn, zf );
					break;
				case PERSPECTIVE:
					return perspectiveRH( perspective.w, perspective.h, zn, zf );
					break;
				case PERSPECTIVE_OFFCENTER:
					return perspectiveOffCenterRH( perspectiveOffCenter.l, perspectiveOffCenter.r,
						perspectiveOffCenter.b, perspectiveOffCenter.t, zn, zf );
					break;
				case PERSPECTIVE_FOV:
					return perspectiveFovRH( perspectiveFov.fovy, perspectiveFov.aspect,
						zn, zf );
					break;
				};
			}
			break;
		case LEFTHANDED:
			switch( projectionType )
			{
			case ORTHO:
				return orthoLH( ortho.w, ortho.h, zn, zf );
				break;
			case ORTHO_OFFCENTER:
				return orthoOffCenterLH( orthoOffCenter.l, orthoOffCenter.r,
					orthoOffCenter.b, orthoOffCenter.t, zn, zf );
				break;
			case PERSPECTIVE:
				return perspectiveLH( perspective.w, perspective.h, zn, zf );
				break;
			case PERSPECTIVE_OFFCENTER:
				return perspectiveOffCenterLH( perspectiveOffCenter.l, perspectiveOffCenter.r,
					perspectiveOffCenter.b, perspectiveOffCenter.t, zn, zf );
				break;
			case PERSPECTIVE_FOV:
				return perspectiveFovLH( perspectiveFov.fovy, perspectiveFov.aspect,
					zn, zf );
				break;
			};
			break;
		};
	}

} // end of poly